package edu.zju.jzs.firstsort.process;

import edu.zju.jzs.firstsort.entity.FlowBean;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * Created by 11544 on 2017/10/13.
 */
public class FlowCountMapper extends Mapper<LongWritable,Text,Text,FlowBean> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
//        super.map(key, value, context);
        String line=value.toString();
        String[] values=line.split("\t");
        try
        {
         String phoneNumber=values[0];
         long upflow=Long.parseLong(values[1]);
         long downflow=Long.parseLong(values[2]);
         FlowBean flowBean=new FlowBean(upflow,downflow);
         context.write(new Text(phoneNumber),flowBean);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }

    }
}
